package com.itheima.d3_exception.Case;


/**
 * @ClassName Case2
 * @Author 16799
 * @Date 2025/7/23 10:08
 * @Version 1.0
 * @Description TODO
 **/
public class Case2 {
    public static void main(String[] args) {
        int arr[] = {1,22,331,44,77};

  /*      //把下面的简化一下：
        try {
            Array(arr);
        }catch (Exception e){
            System.out.println("报错");
            e.printStackTrace();
        }*/

        try {
            Array(arr);
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println("数组索引越界异常");
            e.printStackTrace();
            //throw new RuntimeException(e);
        } catch (ArithmeticException e) {
            System.out.println("除数不为零");
            e.printStackTrace();
            //throw new RuntimeException(e);
        }


    }

    public static void Array(int arr[]) throws ArrayIndexOutOfBoundsException,ArithmeticException{
        int index = arr.length+1;
        System.out.println(arr[index]);
        Divid();
    }
    public static void Divid() throws ArithmeticException{
        System.out.println(100/0);
    }
}
